<include file="Public/head_top"/>
<body>
    <!-- 百度地图 -->
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=m8ILLqprDCS6rhKqLeSCtdZZ"></script>
     <!--配置文件--> 
    <script type="text/javascript" src="__PUBLIC__/ueditor/ueditor.config.js"></script>
     <!--编辑器源码文件--> 
    <script type="text/javascript" src="__PUBLIC__/ueditor/ueditor.all.js"></script>
   
    <input type="hidden" name="deleteURL" id="deleteURL" value="__URL__/deleteSchoolInfo">
    <input type="hidden" name="editorURL" id="editorURL" value="__URL__/editorSchoolInfo">
    <input type="hidden" name="addURL" id="addURL" value="__URL__/addSchoolInfo">
    <input type="hidden" name="school_id" id="school_id" value="{$Think.get.school_id}">
    <div class="content">
        <div class="tab-menu">
            <ul>
                <li class="actived"><a href="#">基础信息</a></li>
                <eq name="condition" value="1">
                <li><a href="#">院系设置</a></li>
                <li><a href="#">高校详情</a></li>
                <li><a href="#">优势专业</a></li>
                <li><a href="#">知名校友</a></li>
                </eq>
                <li><a href="#">学校地址</a></li>
            </ul>
        </div>
        <div class="tab-content">
            <div class="biaoge tab-item actived" id="tab-item-baseinfo">
                <form action="__URL__/schoolAction" enctype="multipart/form-data" method="post" >
                    <input type="hidden" name="school_id" value="{$Think.get.school_id}">
                    <h2>
                        <img src="__ROOT__/{$school.logo}" alt="" id="school-logo">
                        <input type="text" name="school_name" id="school-name" value="{$school.school_name}" placeholder="请填写学校全称...">
                        <div class="img-upload" id="upload-school-logo">
                           <div class="input-file-box">
                               <div class="input-file">
                                   选择图片
                               </div>
                               <input type="file" name="logo">
                           </div>
                        </div>
                    </h2>
                    <div class="tab-box">
                        <div class="title-bar">
                            <p>基础信息</p>
                        </div>
                        <dl class="clearfix">
                            <dt>高校英文名称</dt>
                            <dd id="school-en-name">
                                <input type="text" value="{$school.aliases}" name="aliases">
                            </dd>
                            <dt>高校官网地址</dt>
                            <dd id="school-website" class="samll-dd">
                                <input type="text" value="{$school.website}" name="website">
                            </dd>
                            <dt>院校类型</dt>
                            <dd class="samll-dd" id="school-tpye-0">
                                
                                <volist name="schoolType" id="vo">
                                    <eq name="vo.school_type_sort" value="1">
            
                                    <input type="checkbox" name="schoolTypeId[]" value="{$vo.school_type_id}" 
                                    <volist name="type" id="vot">
                                    <eq name="vot.school_type_id" value="$vo.school_type_id"> checked="checked"</eq>

                                    </volist>
                                    >
                                    <labal> {$vo.school_type_name} </labal>
           
                                    </eq>
                                </volist>

                            </dd>
                            <dt>建校时间</dt>
                            <dd class="samll-dd" id="school-build-time">
                                <input type="text" value="{$school.school_time_year}" name="school_time_year">
                            </dd>
                            <dt>办学类型</dt>
                            <dd class="samll-dd" id="school-tpye-1">
                                <select name="schoolTypeId[]" id="">
                                    <volist name="schoolType" id="vo">
                                        <eq name="vo.school_type_sort" value="4">
                                    <option value="{$vo.school_type_id}"

                                         <volist name="type" id="vot">
                                    <eq name="vot.school_type_id" value="$vo.school_type_id"> selected="selected"</eq>

                                    </volist>

                                    >{$vo.school_type_name}</option>
                                        </eq>
                                    </volist>
                                </select>
                            </dd>
                            <dt>院校性质</dt>
                            <dd class="samll-dd" id="school-tpye-2">
                                <select name="schoolTypeId[]" id="">
                                    <volist name="schoolType" id="vo">
                                        <eq name="vo.school_type_sort" value="5">
                                    <option value="{$vo.school_type_id}"

   <volist name="type" id="vot">
                                    <eq name="vot.school_type_id" value="$vo.school_type_id"> selected="selected"</eq>

                                    </volist>

                                    >{$vo.school_type_name}</option>
                                        </eq>
                                    </volist>
                                </select>
                            </dd>
                            <dt >学院类型</dt>
                            <dd class="samll-dd" id="school-tpye-3">
                                <select name="schoolTypeId[]" id="">
                                    <volist name="schoolType" id="vo">
                                        <eq name="vo.school_type_sort" value="6">
                                    <option value="{$vo.school_type_id}"


    <volist name="type" id="vot">
                                    <eq name="vot.school_type_id" value="$vo.school_type_id"> selected="selected"</eq>

                                    </volist>


                                    >{$vo.school_type_name}</option>
                                        </eq>
                                    </volist>
                                </select>
                            </dd>
                            <dt>院校属性</dt>
                            <dd id="school-extra">
                                  <volist name="schoolType" id="vo">
                                        <eq name="vo.school_type_sort" value="7">
                                    
                                      <input type="checkbox" name="schoolTypeId[]" id="property" value="{$vo.school_type_id}"
 <volist name="type" id="vot">
                                    <eq name="vot.school_type_id" value="$vo.school_type_id"> checked="checked"</eq>

                                    </volist>


                                      >
                                    <label for="property1">{$vo.school_type_name}</label> 
                                        </eq>
                                    </volist>
                             
                            </dd>
                        </dl>
                    </div>
                    <div class="tab-box">
                        <div class="title-bar">
                            <p>主校区地址</p>
                        </div>
                        <ul id="school-address" class="clearfix">
                            <li>
                                <div class="addr-name">
                                    <input type="text" value="{$address.name}" placeholder="校区名称" name="name">
                                </div>
                                <div class="addr-addr">
                                    <select name="province" class="f-ib" id="province" ></select>
                                    <select name="city" class="f-ib" id="city" ></select>
                                    <select name="county" class="f-ib" id="county" ></select>
                                    <input type="text" class="addr-detail" name="school_address" value="{$address.school_address}" placeholder="详细地址">
                                    
                                    <script src="__PUBLIC__/Teachers/js/Area.js"></script>
                                    <script>
                                        var s=["province","city","county"];
                                        var opt0 ="{$address.province}" ? ["{$address.province}","{$address.city}","{$address.county}"]:["省份","地级市","市、县级市"];
                                        function _init_area(){ 
                                            for(i=0;i<s.length-1;i++){
                                              document.getElementById(s[i]).onchange=new Function("change("+(i+1)+")");
                                            }
                                            change(0);
                                        }
                                         _init_area();
                                    </script>
                                </div>
                                <div class="addr-pos">
                                    <input type="text" value="{$address.coordinate_x}" placeholder="经度" name="coordinate_x">
                                    <input type="text" value="{$address.coordinate_y}" placeholder="纬度" name="coordinate_y">
                                    <input type="hidden" value="1" name="main">
                                    <a href="javascript:;" class="btn-modal-pos">获取坐标</a>
                                </div>
                                <div class="addr-zip">
                                    <label>邮编</label>
                                    <input type="text" value="{$address.zip}" placeholder="" name="zip">
                                    <label>电话</label> 
                                    <input type="text" class="" name="phone" value="{$address.phone}" placeholder="">
                                </div>
                            </li>
                        </ul>
                    </div>
                    <div class="btn-group">
                        <input type="submit" value="保存">
                    </div> 
                </form>
            </div>
            <eq name="condition" value="1">
            <div class="biaoge tab-item" id="tab-item-department">
                <div class="btn-box">
                    <a href="javascript:;" class="btn-modal">院系新增</a>
                </div>
                <table>
                    <tr>
                        <th width="20%">学院</th>
                        <th width="60%">院校介绍</th>
                        <th width="20%">管理</th>

                    </tr>
                     <volist name="school_departments" id="vo">
                    <tr>
                        <td>{$vo.name}</td>
                        <td><p>{$vo.content}</p></td>
                        <td>
                             <a href="javascript:;" class="btn-editor" sid="{$vo.departments_id}">编辑</a> | <a href="javascript:;" class="btn-remove" sid="{$vo.departments_id}">删除</a>
                        </td>
                    </tr>
                    </volist>
                </table>
            </div>
            <div class="biaoge tab-item" id="tab-item-detail">
                <table>
                    <tr>
                        <th width="20%">学院</th>
                        <th width="60%">院校介绍</th>
                        <th width="20%">管理</th>
                    </tr>
                    <tr>
                        <td>学校简介</td>
                        <td><p>{$school_info.description}</p></td>
                        <td>
                            <a href="javascript:;" class="btn-editor" sid="{$school_info.info_id}" info-type="description"> 编辑</a> 
                        </td>
                    </tr>
                    <tr>
                        <td>学校历史</td>
                        <td><p>{$school_info.history}</p></td>
                        <td>
                            <a href="javascript:;" class="btn-editor" sid="{$school_info.info_id}" info-type="history">编辑</a> 
                        </td>
                    </tr>
                    <tr>
                        <td>师资力量</td>
                        <td><p>{$school_info.power}</p></td>
                        <td>
                            <a href="javascript:;" class="btn-editor" sid="{$school_info.info_id}" info-type="power">编辑</a> 
                        </td>
                    </tr>
                    <tr>
                        <td>学科建设</td>
                        <td><p>{$school_info.disciplines}</p></td>
                        <td>
                            <a href="javascript:;" class="btn-editor" sid="{$school_info.info_id}" info-type="disciplines">编辑</a> 
                        </td>
                    </tr>
                    <tr>
                        <td>校训</td>
                        <td><p>{$school_info.motto}</p></td>
                        <td>
                            <a href="javascript:;" class="btn-editor" sid="{$school_info.info_id}" info-type="motto">编辑</a>
                        </td>
                    </tr>
                </table>
            </div>
            <div class="biaoge tab-item" id="tab-item-major">
                <div class="btn-box">
                    <a href="javascript:;" class="btn-modal">专业新增</a>
                </div>
                <table>
                    <tr>
                        <th width="160">学院</th>
                        <th width="475">院校介绍</th>
                        <th width="100">管理</th>
                    </tr>
                    <volist name="school_professional" id="vo">
                    <tr>
                        <td>{$vo.name}</td>
                        <td><p>{$vo.summary}</p></td>
                        <td>
                            <a href="javascript:;" class="btn-editor" sid="{$vo.professional_id}">编辑</a> | <a href="javascript:;" class="btn-remove" sid="{$vo.professional_id}">删除</a>
                        </td>
                    </tr>
                   </volist>
                </table>
            </div>
            <div class="biaoge tab-item" id="tab-item-alumni">
                <div class="btn-box">
                    <a href="javascript:;" class="btn-modal">新增</a>
                </div>
                <table>
                    <tr>
                        <th width="160">姓名</th>
                        <th width="475">事迹</th>
                        <th width="100">管理</th>
                    </tr>

                    <volist name="school_alumni" id="vo">
                    <tr>
                        <td>
                            <img src="__PUBLIC__/{$vo.alumni_pic}" alt="">
                            <span>{$vo.alumni_name}</span>
                        </td>
                        <td><p>{$vo.alumni_content}</p></td>
                        <td>
                            <a href="javascript:;" class="btn-editor" sid="{$vo.alumni_id}">编辑</a> | <a href="javascript:;" class="btn-remove" sid="{$vo.alumni_id}">删除</a>
                        </td>
                    </tr>
                  </volist>
                </table>
            </div>
        </eq>
            <div class="biaoge tab-item" id="tab-item-address">
                <div class="btn-box">
                    <a href="javascript:;" class="btn-modal">新增校区</a>
                </div>
                <table>
                    <tr>
                        <th width="20%">校区名称</th>
                        <th width="30%">校区地址</th>
                        <th width="30%">校区坐标</th>
                        <th width="20%">管理</th>
                    </tr>
                    <volist name="school_address" id="vo">
                    <tr data-province="{$vo.province}" data-city="{$vo.city}" data-county="{$vo.county}" data-address="{$vo.school_address}"
                     data-coordinatex="{$vo.coordinate_x}" data-coordinatey="{$vo.coordinate_y}" data-zip="{$vo.zip}" data-phone="{$vo.phone}">
                        <td>{$vo.name}</td>
                        <td>{$vo.province}{$vo.city}{$vo.county}{$vo.school_address}
                        </td>
                        <td>
                            {$vo.coordinate_x},{$vo.coordinate_y}
                        </td>
                        <td>
                            <a href="javascript:;" class="btn-editor" sid="{$vo.address_id}" >编辑</a> | <a href="javascript:;"  sid="{$vo.address_id}"  class="btn-remove">删除</a><neq name="vo.main" value="1">|<a href="javascript:;" class="btn-mainschool" sid="{$vo.address_id}" >设为主校区</a></neq>
                        </td>
                    </tr>
                   </volist>
                </table>
            </div>
        </div>
    </div>
    <!-- 弹框 -->
    <div id="modal">
        <div class="modal-overlay"></div>
        <div class="modal-box" id="modal-department">
            <form action="" method="" name="" editorUrl="__URL__/editorSchoolInfo" addUrl="__URL__/addSchoolInfo">
                <div class="modal-header">
                    <h2>新增院系</h2>
                </div>
                <div class="modal-content">
                    <label for="article-title">学院：</label>
                    <input type="text" name="name" id="article-title" placeholder="请填写文章标题" value="">
                    <label for="article-content">院系介绍：</label>
                    <textarea name="content" id="article-content" value=""></textarea>
                </div>
                <div class="modal-footer">
                    <a href="javascript:;" class="btn-cancel modal-btn">取消</a>
                    <input type="button" value="确定" class="btn-submit modal-btn">
                </div>
            </form>
        </div>
        <div class="modal-box" id="modal-major">
             <form action="" method="" name="" editorUrl="__URL__/editorSchoolInfo" addUrl="__URL__/addSchoolInfo">
                <div class="modal-header">
                    <h2>新增专业</h2>
                </div>
                <div class="modal-content">
                    <label for="article-title">专业名称：</label>
                    <input type="text" name="name" id="article-title" placeholder="请填写专业名称：" value="">
                    <label for="article-content">专业简介：</label>
                    <textarea name="summary" id="article-major" value=""></textarea>
                </div>
                <div class="modal-footer">
                    <a href="javascript:;" class="btn-cancel modal-btn">取消</a>
                    <input type="button" value="确定" class="btn-submit modal-btn">
                </div>
            </form>
        </div>
        <div class="modal-box" id="modal-detail">
            <form action="" method="" name="" editorUrl="__URL__/editorSchoolInfo" addUrl="__URL__/addSchoolInfo">
                <input type="hidden" name="school_id" value="{$Think.get.school_id}">
                <div class="modal-header">
                    <h2>高校详情</h2>
                </div>
                <div class="modal-content">
                    <label for="article-content">内容：</label>
                    <textarea name="" id="article-editor" value=""></textarea>
                </div>
                <div class="modal-footer">
                    <a href="javascript:;" class="btn-cancel modal-btn">取消</a>
                    <input type="button" value="确定" class="btn-submit modal-btn">
                </div>
            </form>
        </div>
        <div class="modal-box" id="modal-alumni">
             <form action="__URL__/FamousAlumni" method="post" name="" enctype="multipart/form-data">
                 <input type="hidden" name="school_id" value="{$Think.get.school_id}">
                <div class="modal-header">
                    <h2>知名校友</h2>
                </div>
                <div class="modal-content">
                    <label for="article-title">校友名称：</label>
                    <input type="text" name="alumni_name" id="article-title" style="width: 450px;margin-right: 200px;" placeholder="" value="">
                    <label for="article-content">校友事迹：</label>
                    <textarea name="alumni_content" id="article-alumni" value=""></textarea>
                    <div class="input-file-box">
                        <div class="input-file">
                            <img src="" alt="">
                        </div>
                        <input type="file" name="alumni_pic"id="alumni_pic">
                    </div>
                </div>
                <div class="modal-footer">
                    <a href="javascript:;" class="btn-cancel modal-btn">取消</a>
                    <input type="submit" value="确认"  class="btn-submit-2 modal-btn">
                </div>
            </form>
        </div>
        <div class="modal-box" id="modal-address">
             <form action="" method="post" name="" editorUrl="__URL__/editorSchoolInfo" addUrl="__URL__/addSchoolInfo">
                <input type="hidden" name="action" value="school_address">
                <div class="modal-header">
                    <h2>学校地址</h2>
                </div>
                <div class="modal-content">
                    <label for="address-name">校区名称：</label>
                    <input type="text" name="name" id="address-name" placeholder="" value="">
                    <label for="">所在地区：</label>
                    <select name="province" class="f-ib" id="province2" ></select>
                    <select name="city" class="f-ib" id="city2" ></select>
                    <select name="county" class="f-ib" id="county2" ></select><br>
                    <script>
                        var s2=["province2","city2","county2"];
                        var opt0 = ["省份","地级市","市、县级市"];
                        // console.log({$address.county});
                        function _init_area2(){ 
                            for(i=0;i<s.length-1;i++){
                              document.getElementById(s2[i]).onchange=new Function("change2("+(i+1)+")");
                            }
                            change2(0);
                        }
                        _init_area2();
                    </script>   
                    <label for="address-detail">详细地址：</label>
                    <input type="text" name="school_address" id="address-detail" placeholder="" value="">
                    <label for="addr-lng">校区经度：</label>
                    <input type="text" name="coordinate_x" id="coordinate_x" placeholder="" value="" style="width:100px">
                    <label for="addr-lat">校区纬度：</label>
                    <input type="text" name="coordinate_y" id="coordinate_y" placeholder="" value="" style="width:100px">
                     <a href="javascript:;" class="btn-modal-pos" style="width:190px;text-align: center;display: inline-block;line-height: 31px;">获取校区坐标</a><br>
                    <label for="address-post">邮编：</label>
                    <input type="text" name="zip" id="zip" placeholder="" value="">
                    <label for="address-post">电话：</label>
                    <input type="text" name="phone" id="phone" placeholder="" value="">
                </div>
                <div class="modal-footer">
                    <a href="javascript:;" class="btn-cancel modal-btn">取消</a>
                    <input type="submit" value="确定" class="btn-submit-2 modal-btn">
                </div>
            </form>
        </div>
    </div>
    <!-- 百度地图弹窗 -->
    <div id="modal-pos" style="">
        <div class="topbar">
            <div class="search-box2">
                <input type="text" class="search-txt">
                <a href="javascript:;" class="btn-search"> 搜索地址 </a>
            </div> 
            <div id="input-lng">
                <label for="input-lng">经度</label><input type="text">
            </div>
            <div id="input-lat">
                <label for="input-lat">纬度</label><input type="text">
            </div>
            <a href="javascript:;" class="btn-submit-pos"> 提交坐标 </a>
            <a href="javascript:;" class="btn-closed-pos"> X </a>
        </div>
        <div class="map" id="mapA"></div>
    </div>
    <script>
        $(function() {

            // 基础信息——上传图片
            moduleAddLogo();
            // 设置院系
            moduleDepartment();
            // 高校详情
            moduleDetail();
            // 优势专业
            moduleMajor();
            // 知名校友
            moduleAlumni();
            // 学校地址
            moduleAddress();

            // 页面加载tab定位
            $(".tab-menu li").eq(sessionStorage.getItem("tabID")).trigger('click');
            $(".tab-menu").on('click', 'li', function() {
                sessionStorage.setItem("tabID",$('.tab-menu li').index(this));
            });
            // 初始化富文本编辑器
            var ue = UE.getEditor('article-content',{
                    initialFrameWidth:620, //初始化宽度
                    initialFrameHeight:240, //初始化高度
                    autoHeightEnabled :false,
                 }
            );

            // 坐标-地图弹窗
            $('.btn-modal-pos').on('click', function(event) {
                if ( $('#modal').is(':hidden')) {
                    showModal();
                }
                $('#modal-pos').show();

                // 初始化地图
                var map = new BMap.Map("mapA");
                var point = new BMap.Point(116.331398,39.897445);
                map.centerAndZoom(point,16);
                map.enableScrollWheelZoom(true);
                // 根据浏览器定位 
                var geolocation = new BMap.Geolocation();
                geolocation.getCurrentPosition(function(r){
                    if(this.getStatus() == BMAP_STATUS_SUCCESS){
                        map.panTo(r.point);
                    }     
                },{enableHighAccuracy: true});
                // 点击搜索
                $('#modal-pos').find('.btn-search').on('click',function(event) {
                    var keyword = $(this).prev().val();
                    // alert(keyword);
                    var local = new BMap.LocalSearch(map, {
                        renderOptions:{map: map}
                    });
                    local.search(keyword);
                });
                // 点击地图的坐标，返回坐标值
                map.addEventListener("click", function(e){      
                       // alert(e.point.lng + ", " + e.point.lat);
                      $('#input-lng').find('input').val(e.point.lng);
                      $('#input-lat').find('input').val(e.point.lat);
                });
                //点击提交，返回坐标值到原来input框
                $('#modal-pos').find('.btn-submit-pos').on('click',function(e) {
                    var lng = $('#input-lng').find('input').val();
                    var lat = $('#input-lat').find('input').val();
                    $('#modal-pos').hide();

                    if ($('#modal-address').is(":hidden")) {
                        $('#tab-item-baseinfo').find('.addr-pos').find('input').eq(0).val(lng);
                        $('#tab-item-baseinfo').find('.addr-pos').find('input').eq(1).val(lat);
                    }else{
                        $('#coordinate_x').val(lng);
                        $('#coordinate_y').val(lat);
                    }
                    if ($('#modal-address').is(":hidden")) {
                        $('#modal').hide();
                        $('#modal .modal-overlay').hide();
                        $('#modal .modal-box').hide();
                        $mask.hide();
                    }
                    return false;
                });
                // 点击关闭弹窗
                $('#modal-pos .btn-closed-pos').on('click', function(event) {
                    $('#modal-pos').hide();
                    if ($('#modal-address').is(":hidden")) {
                        $('#modal').hide();
                        $('#modal .modal-overlay').hide();
                        $('#modal .modal-box').hide();
                        $mask.hide();
                    }
                });
            });
        });
        
    </script>
</body>
</html>